-
Notifications
You must be signed in to change notification settings - Fork 1.4k
add a2ui example #1101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add a2ui example #1101
Conversation
DavdGao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz expose the python code to the top so that we can review the example
|
/gemini review |
| """ | ||
|
|
||
|
|
||
| if __name__ == "__main__": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary code here
|
|
||
| **Use the `execute_shell_command` tool to run (make sure you are in the skill directory):** | ||
| ```bash | ||
| python -m view_a2ui_schema --schema_category BASE_SCHEME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
==》 schema
| .wireit/ | ||
| .angular/ | ||
| *.ts | ||
| *.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping *.ts in .gitignore seems conflict with the current pull request?
|
|
||
| # # --8<-- [start:send_message_streaming] | ||
|
|
||
| # streaming_request = SendStreamingMessageRequest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unnecessary code
| @@ -0,0 +1,110 @@ | |||
| # A2UI in AgentScope | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current directory hierarchy appears to have some redundant nesting:
examples/agent/a2ui_agent
└── samples
└── agent
└── general_agent
├── skills
└── xxx.py
└── client
└── README.md
It seems that the samples/agent/general_agent layers don't serve a clear organizational purpose at the moment. I'd suggest considering a flatter structure:
examples/agent/a2ui_agent
├── skills
├── client
├── xxx.py
└── README.md
|
/gemini help |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds an A2UI example to AgentScope, demonstrating how to integrate A2UI into a ReAct agent. The changes include adding a new example directory with agent and client code, utility functions for A2UI integration, and a README file explaining the example. The review comments identify areas for improvement related to code security and adherence to the repository's code review guide, specifically around lazy loading of dependencies and comment standards. All original comments have been retained as they do not contradict the provided rules.
| name="Friday", | ||
| sys_prompt=get_ui_prompt(), | ||
| model=DashScopeChatModel( | ||
| model_name="qwen-max", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the repository's code review guide (line 11), third-party library dependencies should be imported at the point of use, not at the top of the file. Consider moving this import inside the on_message_send_stream function.
) -> AsyncGenerator[Event, None]:
from agentscope.tool import (
Toolkit,
view_text_file,
execute_python_code,
execute_shell_command,
)
References
- Third-party library dependencies should be imported at the point of use, avoid centralized imports at file top (link)
- Third-party library dependencies should be imported at the point of use, avoid centralized imports at file top. The
Third-party libraryrefers to libraries not included in thedependenciesvariable inpyproject.toml.
| from agentscope.formatter import DashScopeChatFormatter, A2AChatFormatter | ||
| from agentscope.model import DashScopeChatModel | ||
| from agentscope.pipeline import stream_printing_messages | ||
| from agentscope.session import JSONSession | ||
| from agentscope.tool import ( | ||
| Toolkit, | ||
| view_text_file, | ||
| execute_python_code, | ||
| execute_shell_command, | ||
| ) | ||
| from agentscope.message import Msg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the repository's code review guide (lines 45-61), all classes/methods must have complete docstrings, strictly following the template. Please add docstrings to this class.
References
- All classes/methods must have complete docstrings, strictly following the template (link)
| def get_final_structured_output(message: Msg) -> None | str: | ||
| """Get the final structured output from the message.""" | ||
| if isinstance(message.content, list): | ||
| for block in message.content: | ||
| if ( | ||
| isinstance(block, dict) | ||
| and block.get("type") == "tool_use" | ||
| and block.get("name") == "generate_response" | ||
| ): | ||
| input_data = block.get("input") | ||
| if input_data is not None and isinstance(input_data, dict): | ||
| return input_data.get("response_with_a2ui") | ||
| return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the repository's code review guide (lines 45-61), all classes/methods must have complete docstrings, strictly following the template. Please add docstrings to this function.
References
- All classes/methods must have complete docstrings, strictly following the template (link)
| async def _prepare_final_message( | ||
| self, | ||
| formatter: A2AChatFormatter, | ||
| final_msg_text: str | None, | ||
| last_complete_msg: Msg | None, | ||
| ) -> Message: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the repository's code review guide (lines 45-61), all classes/methods must have complete docstrings, strictly following the template. Please add docstrings to this function.
References
- All classes/methods must have complete docstrings, strictly following the template (link)
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. |
AgentScope Version
[The version of AgentScope you are working on, e.g.
import agentscope; print(agentscope.__version__)]Description
Add A2ui example:
In this example, we demonstrate how to integrate A2UI into a ReAct agent in AgentScope. This
implementation is based on the official A2UI agent samples, adapted to use AgentScope's agent
framework.
related issue: #1047
Checklist
Please check the following items before code is ready to be reviewed.
pre-commit run --all-filescommand